home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / klanguagebutton.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  5.8 KB  |  183 lines

  1. /*
  2.  * klangbutton.h - Button with language selection drop down menu.
  3.  *                 Derived from the KLangCombo class by Hans Petter Bieker.
  4.  *
  5.  * Copyright (c) 1999-2003 Hans Petter Bieker <bieker@kde.org>
  6.  *           (c) 2001      Martijn Klingens <klingens@kde.org>
  7.  *
  8.  * Requires the Qt widget libraries, available at no cost at
  9.  * http://www.troll.no/
  10.  *
  11.  *  This program is free software; you can redistribute it and/or modify
  12.  *  it under the terms of the GNU General Public License as published by
  13.  *  the Free Software Foundation; either version 2 of the License, or
  14.  *  (at your option) any later version.
  15.  *
  16.  *  This program is distributed in the hope that it will be useful,
  17.  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
  18.  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  19.  *  GNU General Public License for more details.
  20.  *
  21.  *  You should have received a copy of the GNU General Public License
  22.  *  along with this program; if not, write to the Free Software
  23.  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  24.  */
  25.  
  26.  
  27. #ifndef __KLANGBUTTON_H__
  28. #define __KLANGBUTTON_H__
  29.  
  30. #include <qwidget.h>
  31.  
  32. #include <kdelibs_export.h>
  33.  
  34. class KLanguageButtonPrivate;
  35. class QIconSet;
  36. class QPopupMenu;
  37.  
  38. /**
  39.  * KLanguageButton provides a combobox with a 2-D dataset. It also supports icons.
  40.  * It is also possible to construct a non combobox version.
  41.  *
  42.  * All items are identified using strings, not integers.
  43.  *
  44.  * Combined version of KTagCombo and KLanguageCombo but using a QPushButton
  45.  * instead.
  46.  */
  47. class KDEUI_EXPORT KLanguageButton : public QWidget
  48. {
  49.   Q_OBJECT
  50.  
  51. public:
  52.   /**
  53.    * Constructs a combobox widget with parent parent called name.
  54.    *
  55.    * @param parent The parent of the combo box
  56.    * @param name The name of the combo box
  57.    */
  58.   KLanguageButton(QWidget * parent = 0, const char * name = 0);
  59.   
  60.   /**
  61.    * Constructs a version with static text. The parent parent is called name.
  62.    *
  63.    * @param text The text of the button
  64.    * @param parent The parent of the button
  65.    * @param name The name of the button
  66.    */
  67.   KLanguageButton(const QString & text, QWidget * parent = 0, const char * name = 0);
  68.   
  69.   /**
  70.    * Deconstructor
  71.    */ 
  72.   virtual ~KLanguageButton();
  73.  
  74.   /**
  75.    * Inserts an item into the combo box. A negative index will append the item.
  76.    *
  77.    * @param icon The icon used used when displaying the item.
  78.    * @param text The text string used when displaying the item.
  79.    * @param id The text string used to identify the item.
  80.    * @param submenu The place where the item should be placed.
  81.    * @param index The visual position in the submenu.
  82.    */
  83.   void insertItem( const QIconSet& icon, const QString &text,
  84.                    const QString & id, const QString &submenu = QString::null,
  85.                    int index = -1 );
  86.   /**
  87.    * Inserts an item into the combo box. A negative index will append the item.
  88.    *
  89.    * @param text The text string used when displaying the item.
  90.    * @param id The text string used to identify the item.
  91.    * @param submenu The place where the item should be placed.
  92.    * @param index The visual position in the submenu.
  93.    */
  94.   void insertItem( const QString &text, const QString & id,
  95.                    const QString &submenu = QString::null, int index = -1 );
  96.   /**
  97.    * Inserts a seperator item into the combo box. A negative index will append the item.
  98.    *
  99.    * @param submenu The place where the item should be placed.
  100.    * @param index The visual position in the submenu.
  101.    */
  102.   void insertSeparator( const QString &submenu = QString::null,
  103.                         int index = -1 );
  104.   /**
  105.    * Inserts a submenu into the combo box. A negative index will append the item.
  106.    *
  107.    * @param icon The icon used used when displaying the item.
  108.    * @param text The text string used when displaying the item.
  109.    * @param id The text string used to identify the item.
  110.    * @param submenu The place where the item should be placed.
  111.    * @param index The visual position in the submenu.
  112.    */
  113.   void insertSubmenu( const QIconSet & icon, const QString &text,
  114.                       const QString & id, const QString &submenu = QString::null,
  115.                       int index = -1);
  116.   /**
  117.    * Inserts a submenu into the combo box. A negative index will append the item.
  118.    *
  119.    * @param text The text string used when displaying the item.
  120.    * @param id The text string used to identify the item.
  121.    * @param submenu The place where the item should be placed.
  122.    * @param index The visual position in the submenu.
  123.    */
  124.   void insertSubmenu( const QString &text, const QString & id,
  125.                       const QString &submenu = QString::null, int index = -1);
  126.  
  127.  
  128.   void insertLanguage( const QString& path, const QString& name,
  129.                        const QString& sub = QString::null,
  130.                        const QString &submenu = QString::null, int index = -1);
  131.  
  132.  
  133.   int count() const;
  134.   /**
  135.    * Removes all combobox items.
  136.    */
  137.   void clear();
  138.   /**
  139.    * Changes the current text item of the combobox, and makes the text static.
  140.    */
  141.   void setText(const QString & text);
  142.   /**
  143.    * Returns the id of the combobox's current item.
  144.    */
  145.   QString current() const;
  146.   /**
  147.    * Returns TRUE if the combobox contains id.
  148.    */
  149.   bool contains( const QString & id ) const;
  150.   /**
  151.    * Sets id as current item.
  152.    */
  153.   void setCurrentItem( const QString & id );
  154.  
  155.     QString id( int i ) const;
  156.  
  157. signals:
  158.   /**
  159.    * This signal is emitted when a new item is activated. The id is
  160.    * the identificator of the selected item.
  161.    */
  162.   void activated( const QString & id );
  163.   void highlighted( const QString & id );
  164.  
  165. private slots:
  166.   void slotActivated( int );
  167.   void slotHighlighted( int );
  168.  
  169. private:
  170.   int currentItem() const;
  171.   void setCurrentItem( int );
  172.   void init(const char * name);
  173.  
  174.   // work space for the new class
  175.   QStringList *m_ids;
  176.   QPopupMenu *m_popup, *m_oldPopup;
  177.   int m_current;
  178.  
  179.   KLanguageButtonPrivate * d;
  180. };
  181.  
  182. #endif
  183.